package com.sumainfor.pc.market.controller;

import com.sumainfor.common.util.JsonResult;
import com.sumainfor.common.utlis.PageUtils;
import com.sumainfor.common.utlis.Pager;
import com.sumainfor.pc.market.dao.HoConfigMapper;
import com.sumainfor.pc.market.service.HoConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author Meng
 * @ClassName HoConfigController
 * @date 2020/1/12 15:18
 * @description: TODO
 */
@Controller
@RequestMapping("/HoConfig")
public class HoConfigController {

    @Autowired
    HoConfigService hoConfigService;

    @ResponseBody
    @GetMapping("/getHouConfigList")
    public JsonResult getHouConfigList(@RequestParam Map<String,Object> params, Pager pager){

        pager.setPageno(Integer.parseInt(params.get("pageno").toString()));
        pager.setPagesize(Integer.parseInt(params.get("pagesize").toString()));
        pager.setPagerNecessary(params, pager);
        PageUtils pageUtils = new PageUtils();
        Integer cout =  hoConfigService.getHouConfigListCount(params);
        System.out.println("cout"+cout);
        if(cout == 0){
            return pageUtils.getJsonResult(new ArrayList<Map<String,Object>>(),params,cout);
        }else {
            List<Map<String, Object>> getHouConfigList = hoConfigService.getHouConfigList(params);
            return pageUtils.getJsonResult(getHouConfigList,params,cout);
        }

    }




}
